import pymysql


def get_conn():
    # 建立连接
    conn = pymysql.connect(host="localhost",
                           user="root",
                           password="459gjy217",
                           db="test",
                           charset="utf8")
    # c创建游标A
    cursor = conn.cursor()
    return conn, cursor


def close_conn(conn, cursor):
    if cursor:
        cursor.close()
    if conn:
        conn.close()


def query(sql, *args):
    conn, cursor = get_conn()
    cursor.execute(sql, args)
    res = cursor.fetchall()
    close_conn(conn, cursor)
    return res


def get_l1_data():
    sql = "SELECT * FROM 乔丹数据 WHERE season = '87-88' "
    res = query(sql)
    return res[0]


def get_r1_data():
    sql = "SELECT * FROM 乔丹数据 WHERE season = '87-88' "
    res = query(sql)
    return res[0]


if __name__ == "__main__":
    print(get_l1_data())
